
import Web3 from "web3";
export const getWeb3 = async (): Promise<any> => {
    let web3Provider;
    if (typeof window.ethereum !== 'undefined') {
        web3Provider = window.ethereum
    } else {
        web3Provider = new Web3.providers.HttpProvider('https://bsc-dataseed.binance.org/')
    }
    const web3 = new Web3(web3Provider);
    const networkId = await web3.eth.net.getId()
    let userAddr = ''
    return {
        isListening: web3.eth.net.isListening(),
        userAddr,
        networkId,
        web3() {
            return web3
        }
    }
}
